<!-- 219970848 周琦 -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div class="center">
			<table>
				<tr>
					<td class="td_left"><label for="username">用户名 ：</label> </td>
					<td><input type="text" name="username" id="username"> </td>
					<td>当用户名为刘备时重名</td>
				</tr>
				<td colspan="1" align="center">
					<input type="submit" value="判断" id="login">
				</td>
				<tr>
					<td class="td_left" id="txt"></td>
				</tr>
				<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
				<script>
					$("#login").click(function() {
						$.ajax({
							type: 'GET',
							url: 'https://mock.apifox.cn/m1/2801413-0-default/user',
							data: {
								name: $('#username').val()
							},
							dataType: 'json',
							success: function(res) {
								if (res.name == $('#username').val()) {
									$("#txt").text("用户已经存在");
								} else {
									$("#txt").text("用户名有效");
								}
							}
						})
					})
				</script>
		</div>
	</body>
</html>